package Kuaishou;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.BeanUtils;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import scala.Int;

/**
 * @author leiwenkang <leiwenkang@kuaishou.com>
 * Created on 2021-04-14
 */
public class Test33深克隆 {
    public static void main(String[] args) {
        MyDemo1 demo1 = new MyDemo1(1, "lwk", 18, Lists.newArrayList("tangyuan"));
        MyDemo2 demo2 = new MyDemo2();
        BeanUtils.copyProperties(demo1, demo2);

        System.out.println(demo1);
        System.out.println(demo2);

        MyDemo1 demo3 = new MyDemo1(1, "lwk", 18, Lists.newArrayList("tangyuan"));
        MyDemo2 demo4 = new MyDemo2(2, "fxy", 2, null);
        BeanUtils.copyProperties(demo3, demo4);
        System.out.println(demo3);
        System.out.println(demo4);
        System.out.println(demo3.getChilds());
        System.out.println(demo4.getChilds());

        Map<Long, Double> map1 = Maps.newHashMap();
        map1.put(1L, 0.5);
        Map<Long, Double> map2 = Maps.newHashMap();
        map2.putAll(map1);

        System.out.println(map1);
        System.out.println(map2);
        map2.put(2L, 0.5);
        System.out.println(map1);
        System.out.println(map2);

        Set<Integer> set1 = Sets.newHashSet();
        set1.add(1);
        Set<Integer> set2 = Sets.newHashSet();
        set2.addAll(set1);

        System.out.println(set1);
        System.out.println(set2);
        set2.add(2);
        System.out.println(set1);
        System.out.println(set2);


    }
}

@Data
@NoArgsConstructor
@AllArgsConstructor
class MyDemo1 {
    private int id;
    private String name;
    private int age;
    private List<String> childs;
}

@Data
@NoArgsConstructor
@AllArgsConstructor
class MyDemo2 {
    private int id;
    private String name;
    private int sex;
    private List<String> childs;
}
